#include<bits/stdc++.h>
using namespace std;
#define int long long
int read()
{
    int a=0,b=1;
    char c='\0';
    while(c<'0' || c>'9')
    {
        if(c=='-')
        {
            b*=-1;
        }
        c=getchar();
    }
    while(c>='0' && c<='9')
    {
        a=(a<<3)+(a<<1)+(c-'0');
        c=getchar();
    }
    return a*b;
}

const int MAXN=100005;
int d[MAXN],v[MAXN],a[MAXN];
int p[MAXN],dt[MAXN];

bool isSp(int d,int v,int a,int pt,int vt,int l)
{
    int v2=v*v+2*a*(pt-d);

    if(v2-v*v>2*a*l)
    {
        //return false;
    }

    return v2>vt*vt;
}

bool u[MAXN];
int dfs(int i,int n)
{
    if(i<n)
    {
        u[i]=1;
        int X=dfs(i+1,n);
        u[i]=0;
        int Y=dfs(i+1,n);
        return max(X,Y);
    }
    int ans1=0,ans2=0;
    for(int i=1;i<=n;i++)
    {
        if(u[i])
        {
            continue;
        }
        ans2++;
    }
    if(ans2)
    {

    }
    return ans2;
}

signed main()
{
    srand(time(0));
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int T;
    cin>>T;
    for(int TT=1;TT<=T;TT++)
    {
        int n,m,L,V;
        n=read();m=read();L=read();V=read();
        //cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)
        {
            d[i]=read();v[i]=read();a[i]=read();
            //cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++)
        {
            p[i]=read();
            //cin>>p[i];
            for(int j=1;j<=n;j++)
            {
                if(p[i]<d[j])
                {
                    continue;
                }
                if(isSp(d[j],v[j],a[j],p[i],V,L))
                {
                    //cout<<j<<"<-"<<i<<' ';
                    dt[j]++;
                }
            }
            cout<<endl;
        }
        int ans1=0;
        for(int i=1;i<=n;i++)
        {
            //cout<<i<<':'<<dt[i]<<endl;
            if(dt[i])
            {
                ans1++;
            }
        }
        int ans2=dfs(1,m);
        //cout<<"------------"<<TT<<':'<<ans1<<endl;
        cout<<ans1<<' '<<m*ans1/(n+rand()%3-1)<<endl;
    }
    return 0;
}
